package com.example.jerry.test;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.loginandpaytools.LoginAndPayToolSDK;
import com.example.loginandpaytools.Support.Configuration;
import com.example.loginandpaytools.Utils.HttpCallbackListener;

public class MainActivity extends AppCompatActivity {

    private Button mButton1;
    private Button mButton2;
    private Button mButton3;
    private Button mButton4;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mButton1 = (Button) findViewById(R.id.button1);
        mButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });



        mButton2 = (Button) findViewById(R.id.button2);
        mButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                /**
                 * 调用角色登陆接口,只需实现onFinish()以及onError()方法
                 */
                LoginAndPayToolSDK.roleLogin(MainActivity.this, new HttpCallbackListener() {
                    @Override
                    public void onFinish() {
                        Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onFinish(String code) {

                    }

                    @Override
                    public void onFinish(String username, String password) {

                    }

                    @Override
                    public void onError(Exception e) {
                        Toast.makeText(MainActivity.this, e.getMessage(),Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });

        /**
         *设置公共参数
         */
        setConfig();

        /**
         * 激活接口
         */
        LoginAndPayToolSDK.activeInterface(getApplicationContext(), new HttpCallbackListener() {
            @Override
            public void onFinish() {

            }

            @Override
            public void onFinish(String code) {

            }

            @Override
            public void onFinish(String username, String password) {

            }

            @Override
            public void onError(Exception e) {

            }
        });

        mButton3 = (Button) findViewById(R.id.button3);
        mButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, PayActivity.class);
                startActivity(intent);
            }
        });

        mButton4 = (Button) findViewById(R.id.button4);
        mButton4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, com.example.jerry.test.FabButtonActivity.class);
                startActivity(intent);
            }
        });
    }

    private void setConfig() {
        //相关的值需要替换
        //渠道id
        Configuration.setChannelId(1);
        //游戏id
        Configuration.setGameId(1);
        //包标识
        Configuration.setPackageName("com.ios.xxqxz");
        //服务器id
        Configuration.setServerId(1);
    }


    @Override
    protected void onDestroy() {

        super.onDestroy();

    }


}
